/**
* 自定义progressBar
*/
import React, { Component } from 'react';
import { View, Text, StyleSheet, ActivityIndicator } from "react-native";

class ProgressView extends Component {

    constructor(props) {
        super(props);
    }

    render() {
        let { show, tip, hasTitleBar } = this.props;
        let marginBottom = (hasTitleBar === true) ? 44 : 0
        if (show) {
            return (
                <View style={[styles.progress, { marginBottom }]}>
                    <View style={{ alignItems: 'center', justifyContent: 'center', borderRadius: 10, backgroundColor: 'rgba(0,0,0,0.8)', paddingTop: 20, paddingLeft: 20, paddingRight: 18, paddingBottom: 18 }}>
                        <ActivityIndicator color={'white'} animating={true} size={'large'} />
                        {
                            tip ?
                                <Text style={{ fontSize: 14, color: 'white', marginTop: 10 }}>{tip}</Text>
                                :
                                null
                        }
                    </View>
                </View>
            )
        } else {
            return null;
        }
    }

}

const styles = StyleSheet.create({
    progress: {
        position: 'absolute',
        top: 0,
        bottom: 0,
        left: 0,
        right: 0,
        backgroundColor: 'transparent',
        alignItems: 'center',
        justifyContent: 'center'
    }
})
module.exports.ProgressView = ProgressView
